﻿using Git.Framework.Cache;
using Git.Framework.DataTypes.ExtensionMethods;

using Git.Storage.Entity.Store;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Transactions;
using Git.Framework.ORM;

namespace Git.Storage.Provider.Store
{
    public partial class AuditeProvider : DataFactory
    {
        ////private readonly Log log = Log.Instance(typeof(AuditeProvider));

        public AuditeProvider() { }

        /// <summary>
        /// 新增任务单
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Add(AuditeEntity entity)
        {
            entity.IncludeAll();
            int line = this.Audite.Add(entity);
            if (line > 0)
            {
                CacheHelper.Remove(CacheKey.JOOSHOW_AUDITE_CACHE);
            }
            return line;
        }

        /// <summary>
        /// 在缓存中查询对象
        /// </summary>
        /// <param name="OrderNum"></param>
        /// <returns></returns>
        //public AuditeEntity GetAuditeByCache(string OrderNum)
        //{
        //    List<AuditeEntity> listResult = CacheHelper.Get<List<AuditeEntity>>(CacheKey.JOOSHOW_AUDITE_CACHE);
        //    if (!listResult.IsNullOrEmpty())
        //    {
        //        return listResult.FirstOrDefault(a => a.OrderNum == OrderNum);
        //    }
        //    return null;
        //}

        /// <summary>
        /// 根据单号
        /// </summary>
        /// <param name="OrderNum"></param>
        /// <returns></returns>
        public AuditeEntity GetSingleByOrderNum(string OrderNum)
        {
            AuditeEntity entity = new AuditeEntity();
            entity.IncludeAll();
            entity.Where(a => a.OrderNum == OrderNum);
            entity = this.Audite.GetSingle(entity);
            return entity;
        }
    }
}
